<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/11/23
 * Time: 11:57
 */

namespace app\api\model;

use app\api\service\User as UserService;

class User extends BaseModel
{
    protected $hidden = ['openid','password','salt'];

    public function getIsMemberAttr($value,$data){
        return UserService::isMember($data['member_time']);
    }

    //推荐人昵称
    public function pUser()
    {
        return $this->belongsTo('User', 'parentid', 'id')->bind(['p_nickname' => 'nickname']);
    }

    //扣除金币
    public static function deductGold($user_id, $amount)
    {

    }

    public function getWaitMoneyAttr($value)
    {
        if ($value < 0) {
            return 0;
        }else{
            return $value;
        }
    }
}